//
//  WSShopCarViewController.m
//  WisdomStar
//
//  Created by 谭飞 on 2018/10/24.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "WSShopCarViewController.h"

@interface WSShopCarViewController ()

@property (weak, nonatomic) IBOutlet UIView *indicatorView;
@property (weak, nonatomic) IBOutlet UIButton *lessonBtn;

@property (nonatomic, strong) UIButton *lastSelectBtn;

@end

@implementation WSShopCarViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.lastSelectBtn = self.lessonBtn;
    [self setupNavButton];
}

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];

    [self.indicatorView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.lessonBtn.titleLabel);
        make.bottom.offset(0);
        make.width.offset(18.f);
        make.height.mas_equalTo(4.f);
    }];
}

- (void)setupNavButton {
    UIBarButtonItem *rightItem = [UIBarButtonItem createBarButtonItemWithTitle:@"管理" titleColor:COLOR_HEX(0xE5FFFB) target:self action:@selector(rightItemTaped)];
    self.navigationItem.rightBarButtonItem = rightItem;
}

#pragma mark - Actions

- (void)rightItemTaped {
    
}

- (IBAction)menuBtnClicked:(UIButton *)sender {
    if (_lastSelectBtn == sender) return;
    sender.selected = YES;
    self.lastSelectBtn.selected = NO;
    self.lastSelectBtn = sender;
    // animation
    [UIView animateWithDuration:0.25f delay:0.f options:UIViewAnimationOptionCurveEaseInOut animations:^{
        self.indicatorView.xmg_centerX = sender.xmg_centerX;
    } completion:^(BOOL finished) {
        
    }];
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
